﻿using System.Diagnostics;

namespace Application.Utils
{
    public class SystemInfo
    {
        public static string SeverInfo()
        {
            string script = "echo 'Hello, World!66666666'"; // 替换为你的脚本内容

            var process = new Process();
            process.StartInfo.FileName = "bash"; // 使用bash来执行脚本
            process.StartInfo.Arguments = "-c \"" + script + "\"";
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;

            process.Start();

            string output = process.StandardOutput.ReadToEnd();
            string error = process.StandardError.ReadToEnd();

            process.WaitForExit();
            int exitCode = process.ExitCode;

            return new { output = output, error = error, exitCode = exitCode }.ToJson();
        }
    }
}
